using Game1942.Library;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Game1942
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class GameContext : Microsoft.Xna.Framework.Game
    {
        #region [ Attributes ]
        private readonly GraphicsDeviceManager graphics;

        public GraphicsDeviceManager Graphics
        {
            get { return graphics; }
        }

        private SpriteBatch spriteBatch;

        public SpriteBatch SpriteBatchField
        {
            get { return spriteBatch; }
        }

        private State state;

        public State State
        {
            get { return state; }
            set { state = value; }
        }
        #endregion



        public GameContext()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.PreferredBackBufferWidth = Constants.Screen.Width;
            graphics.PreferredBackBufferHeight = Constants.Screen.Height;
        }

        
        #region [ Load Content ]
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            state = new MainMenu(this,Content,GraphicsDevice);
        }
        #endregion

        #region [ Unload Content ]
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }
        #endregion

        protected override void Update(GameTime gameTime)
        {
            state.Update(gameTime);
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            state.Draw(gameTime);
            base.Draw(gameTime);
        }
    }
}
